home *** CD-ROM | disk | FTP | other *** search
- Path: engnews2.Eng.Sun.COM!usenet
- From: nitin@more.eng.sun.com (Nitin More [CONTRACTOR])
- Newsgroups: comp.lang.c++
- Subject: Re: Help- pointers to functions
- Date: 19 Jan 1996 18:05:26 GMT
- Organization: SunSoft
- Distribution: world
- Message-ID: <NITIN.96Jan19100526@more.eng.sun.com>
- References: <4djcn5$hfe@matrix.mdn.com>
- NNTP-Posting-Host: more.eng.sun.com
- In-reply-to: G. Ball's message of 17 Jan 1996 17:47:17 GMT
-
- In article <4djcn5$hfe@matrix.mdn.com> G. Ball <gball@aggie.mdn.com> writes:
-
-
- You could get the answer to this in any decent C++ book. Look for "pointer to
- function" section. To make your life easier, you could use typedef and then
- use the new type as any other type. So you could easily define array of this
- new type. For example,
-
- typedef int (*FunctionType)(const char *str);
-
- Here you have defined a new type called FunctionType which is a pointer to a
- function which takes const char* as an argument and returns an int. Now you
- can define the array as follows:
-
- FunctionType *functionArray[100];
-
- functionArray[0] = &Cut;
- functionArray[1] = &Paste;
-
- -Nitin
-
-
- > From: G. Ball <gball@aggie.mdn.com>
- > Newsgroups: comp.lang.c++
- > Date: 17 Jan 1996 17:47:17 GMT
- > Organization: G. Ball
- > X-XXDate: Wed, 17 Jan 1996 13:04:01 GMT
- >
- >
- > I need your help!
- >
- > I am putting together a set of subroutines that I hope to place in
- > several models.
- > The problem is I have an unspecified number of function, each requiring
- > the same input
- > and I would like to refer to them using an array (ie.
- > (*function[i])(variable) or something).
- > Is it possible or do you have any ideas on alternate solutions?
- >
- > Thank you for your time and efforts.
- > John
- > jschell@aggie.mdn.com
- --
- ----------------------------------------------------------------------
- Nitin More
- SunSoft, Bldg 16 Off: (415) 786 7109
- Menlo Park, CA Fax: (415) 786 7957 e-mail: nitin@more.eng.sun.com
- ----------------------------------------------------------------------
-